package view;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.WindowConstants;
import javax.swing.JFrame;
import javax.swing.JLabel;

import controller.Maquina;
import controller.exception.MaquinaInstantiationException;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class MenuPpal extends javax.swing.JPanel {
	private JButton botonCrearMaquina;
	private JButton botonCargaPremio;
	private JButton botonCargaRodillos;
	private JButton botonCrearComodin;
	private JButton botonCargarSimples;
	private JLabel textoElegirOperacion;

	/**
	* Auto-generated main method to display this 
	* JPanel inside a new JFrame.
	*/
	public static void main(String[] args) {
		JFrame frame = new JFrame();
		frame.getContentPane().add(new MenuPpal());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
	public MenuPpal() {
		super();
		try {
			Maquina maquina=Maquina.getInstancia();
			abrirVentanaJugar();
		} catch (MaquinaInstantiationException e) {
			initGUI();
		}
		
	}
	
	private void initGUI() {
		try {
			this.setPreferredSize(new java.awt.Dimension(291, 298));
			this.setLayout(null);
			{
				botonCrearMaquina = new JButton();
				this.add(botonCrearMaquina);
				botonCrearMaquina.setText("Crear Maquina");
				botonCrearMaquina.setBounds(29, 52, 233, 41);
				
				botonCrearMaquina.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						abrirVentanaCrearMaquina(evt);
					}
				});
				
			}
			{
				textoElegirOperacion = new JLabel();
				this.add(textoElegirOperacion);
				textoElegirOperacion.setText("Elija la operacion:");
				textoElegirOperacion.setBounds(29, 21, 163, 19);
			}
			{
				botonCargarSimples = new JButton();
				this.add(botonCargarSimples);
				botonCargarSimples.setText("Cargar Casillas Simples");
				botonCargarSimples.setBounds(29, 98, 233, 43);
				
				botonCargarSimples.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						abrirVentanaCargaCasillasSimples(evt);
					}
				});
				
			}
			{
				botonCrearComodin = new JButton();
				this.add(botonCrearComodin);
				botonCrearComodin.setText("Crear Casilla Comodin");
				botonCrearComodin.setBounds(29, 146, 233, 41);
				
				botonCrearComodin.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						abrirVentanaCrearCasillaComodin(evt);
					}
				});
				
			}
			{
				botonCargaRodillos = new JButton();
				this.add(botonCargaRodillos);
				botonCargaRodillos.setText("Cargar Rodillos");
				botonCargaRodillos.setBounds(29, 192, 233, 38);
				
				botonCargaRodillos.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						abrirVentanaCargaRodillos(evt);
					}
				});
				
			}
			{
				botonCargaPremio = new JButton();
				this.add(botonCargaPremio);
				botonCargaPremio.setText("Cargar Premios");
				botonCargaPremio.setBounds(29, 235, 233, 41);
				
				botonCargaPremio.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent evt)
					{
						abrirVentanCargaPremios(evt);
					}
				});
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void abrirVentanCargaPremios(ActionEvent evt) {
		// TODO Auto-generated method stub
		System.out.println("cargarPremios.actionPerformed, event="+evt);
		JFrame frame = new JFrame();
		frame.getContentPane().add(CargarPremio.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	protected void abrirVentanaCargaRodillos(ActionEvent evt) {
		// TODO Auto-generated method stub
		System.out.println("cargarRodillos.actionPerformed, event="+evt);
		JFrame frame = new JFrame();
		frame.getContentPane().add(CargarRodillo1.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	protected void abrirVentanaCrearCasillaComodin(ActionEvent evt) {
		// TODO Auto-generated method stub
		System.out.println("crearComodin.actionPerformed, event="+evt);
		JFrame frame = new JFrame();
		frame.getContentPane().add(CrearComodinElegirCantidad.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	protected void abrirVentanaCargaCasillasSimples(ActionEvent evt) {
		System.out.println("cargarSimple.actionPerformed, event="+evt);
		JFrame frame = new JFrame();
		frame.getContentPane().add(CargarSimple.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}

	protected void abrirVentanaCrearMaquina(ActionEvent evt) {
		// TODO Auto-generated method stub
		System.out.println("crearMaquina.actionPerformed, event="+evt);
		JFrame frame = new JFrame();
		frame.getContentPane().add(CrearMaquina.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	protected void abrirVentanaJugar() throws MaquinaInstantiationException{
		JFrame frame = new JFrame();
		frame.getContentPane().add(MenuJugar.getInstancia());
		frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		frame.pack();
		frame.setVisible(true);
	}
	
}
